package com.jsy.common.util;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.cvm.v20170312.CvmClient;
import com.tencentcloudapi.cvm.v20170312.models.DescribeZonesRequest;
import com.tencentcloudapi.cvm.v20170312.models.DescribeZonesResponse;

public class TencentCloudUtil {

    public static void main(String[] args) {
        DescribeZonesRequest req = new DescribeZonesRequest();
        setParam(req);
        sendRequest(req);

    }

    /**
     * 截图模板
     * @param req
     */
    private static void setParam(DescribeZonesRequest req) {
        req.set("Action","CreateLiveSnapshotTemplate");
        req.set("Version","2018-08-01");
        req.set("TemplateName","模板名称");
        req.set("CosAppId","Cos 应用 ID");
        req.set("CosBucket","Cos Bucket名称");
        req.set("CosRegion","Cos地区");
        req.set("Description","描述信息");
        req.set("SnapshotInterval","截图间隔");
    }

    public static DescribeZonesResponse sendRequest(DescribeZonesRequest req) {
        try {
            // 实例化一个认证对象，入参需要传入腾讯云账户 s e c r e t I d ，s e c r e t K e y
            Credential cred = new Credential("secretId", "secretKey");

// 实例化要请求产品（以 C V M 为例）的 c li e n t 对象
            CvmClient client = new CvmClient(cred, "ap-guangzhou");

// 实例化一个请求对象
//            DescribeZonesRequest req = new DescribeZonesRequest();

// 通过 c li e n t 对象调用想要访问的接口，需要传入请求对象
            DescribeZonesResponse resp = client.DescribeZones(req);

// 输出 J S O N 格式的字符串回包
            System.out.println(DescribeZonesRequest.toJsonString(resp));
            return resp;
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
        return null;
    }

    public static void proxy() {
        //方式一
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setProxyHost("真实代理IP");
        httpProfile.setProxyPort(2);
        //方式二
        System.setProperty("https.proxyHost","真实代理IP");
        System.setProperty("https.proxyPort","真实代理端口");
    }
}
